package com.erp.ae.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: 拉取AE订单 服务交换机 队列设置
 * @Author: j.zh
 * @Date: 2024/5/2
 * @Version: 4.0.0
**/
@Configuration
public class PullOrderMQConfig {

    /**
     * 拉取AE订单交换机
     * TopicExchange
     * 创建topic类型的交换机
     * @return
     */
    @Bean
    public Exchange pullOrderEventExchange() {
        return new TopicExchange("pull-order-event-exchange", true, false);
    }

    /**
     * 初始化BOM队列-拉取AE新订单
     * @return
     */
    @Bean
    public Queue saleSystemQueue() {
        Queue queue = new Queue("pull.new.order.queue", true, false, false);
        return queue;
    }

    @Bean
    public Queue incrementalOrderQueue() {
        Queue queue = new Queue("pull.incremental.order.queue", true, false, false);
        return queue;
    }

    @Bean
    public Binding saleSystemBinding() {
        // 新订单业务分发
        return new Binding("pull.new.order.queue",
                Binding.DestinationType.QUEUE,
                "pull-order-event-exchange",
                "pull.new.order.divide",
                null);
    }

    @Bean
    public Binding incrementalOrderBinding() {
        // 新订单业务分发
        return new Binding("pull.incremental.order.queue",
                Binding.DestinationType.QUEUE,
                "pull-order-event-exchange",
                "pull.incremental.order.divide",
                null);
    }


}

